package com.zrz.XmlUtils;


import com.zrz.domain.Image;
import com.zrz.domain.ImageMessage;
import com.zrz.domain.TextMessage;
import com.zrz.util.LogUtils;

import java.util.Date;


public class MessageUtil {
	public static final String MSGTYPE_EVENT = "event";
	public static final String MESSAGE_SUBSCIBE = "subscribe";
	public static final String MESSAGE_UNSUBSCIBE = "unsubscribe";
	public static final String MESSAGE_TEXT = "text";
	public static final String EVENT_TYPE_CLICK = "CLICK";

	public static String textMsg(String toUserName,String fromUserName,String content){
		TextMessage text = new TextMessage();
		text.setFromUserName(toUserName);
		text.setToUserName(fromUserName);
		text.setMsgType(MESSAGE_TEXT);
		text.setCreateTime(new Date().getTime());
		text.setContent(content);
		return XmlUtil.textMsgToxml(text);
	}
	public static  String imageMsg(String toUserName,String fromUserName,String mediaId){
		ImageMessage imageMessage=new ImageMessage();
		Image image=new Image();
		image.setMediaId(mediaId);
		imageMessage.setImage(image);
		imageMessage.setFromUserName(fromUserName);
		imageMessage.setToUserName(toUserName);
		imageMessage.setCreateTime(new Date().getTime());
		imageMessage.setMsgType("image");
		String s=XmlUtil.imageMsgToxml(imageMessage);
		LogUtils.info(s);
		return s;
	}

	public static String subscribeForText(String toUserName,String fromUserName){
		return textMsg(toUserName, fromUserName, "");
	}
	

	public static String unsubscribe(String toUserName,String fromUserName){
		return "";
	}
}
